package com.tj.template.application.trade.input;

import com.fqgj.common.api.ParamsObject;
import com.tj.bo.common.conf.util.ParamsValidateUtil;
import com.tj.bo.trade.client.enums.CoinTypeEnum;
import com.tj.bo.trade.client.enums.TradeTypeEnum;
import com.tj.bo.trade.client.enums.TrendTypeEnum;
import org.apache.commons.lang3.StringUtils;

/**
 * @program: binary-option
 * @description
 * @author: binary
 * @create: 2020-06-11 09:50
 **/
public class CreateTradeRequest extends ParamsObject {

    /**
     * 产品code
     */
    private String productCode;
    /**
     * 交易类型 0：虚拟交易 1：真实交易
     */
    private Integer tradeType;
    /**
     * 0：跌 1：涨
     */
    private Integer trendType;
    /**
     * 货币类型
     */
    private Integer coinType;
    /**
     * 下单金额
     */
    private String amount;
    /**
     * 开盘时间
     */
    private String openingTime;
    /**
     * 开盘价格
     */
    private String openingPrice;

    public String getOpeningTime() {
        return openingTime;
    }

    public CreateTradeRequest setOpeningTime(String openingTime) {
        this.openingTime = openingTime;
        return this;
    }

    public String getOpeningPrice() {
        return openingPrice;
    }

    public CreateTradeRequest setOpeningPrice(String openingPrice) {
        this.openingPrice = openingPrice;
        return this;
    }

    public String getProductCode() {
        return productCode;
    }

    public CreateTradeRequest setProductCode(String productCode) {
        this.productCode = productCode;
        return this;
    }

    public Integer getTradeType() {
        return tradeType;
    }

    public CreateTradeRequest setTradeType(Integer tradeType) {
        this.tradeType = tradeType;
        return this;
    }

    public Integer getTrendType() {
        return trendType;
    }

    public CreateTradeRequest setTrendType(Integer trendType) {
        this.trendType = trendType;
        return this;
    }

    public Integer getCoinType() {
        return coinType;
    }

    public CreateTradeRequest setCoinType(Integer coinType) {
        this.coinType = coinType;
        return this;
    }

    public String getAmount() {
        return amount;
    }

    public CreateTradeRequest setAmount(String amount) {
        this.amount = amount;
        return this;
    }

    @Override
    public void validate() {
        ParamsValidateUtil.checkParams(StringUtils.isBlank(productCode), "productCode can not be empty");
        ParamsValidateUtil.checkParams(TradeTypeEnum.getEnumByCode(tradeType) == null, "tradeType is invalid");
        ParamsValidateUtil.checkParams(TrendTypeEnum.getEnumByCode(trendType) == null, "trendType is invalid");
        ParamsValidateUtil.checkParams(CoinTypeEnum.getEnumByCode(coinType) == null, "coinType is invalid");
        ParamsValidateUtil.checkParams(StringUtils.isBlank(amount), "amount can not be empty");
        ParamsValidateUtil.checkParams(StringUtils.isBlank(openingTime), "openingTime can not be empty");
        //ParamsValidateUtil.checkParams(StringUtils.isBlank(openingPrice), "openingPrice can not be empty");
    }
}
